package bas.gps_fiets;


public class Direction{
	
	
	
//	current new location
	public double LatA;
	public double LongA;

//	new destination
	public double LatB;
	public double LongB;
	
//	Old current location
	public double LatC;
	public double LongC;
	
	double LatDifference;
	double LongDifference;
	
	double Longdistance;
	double Latdistance;
	
	public int directionIHaveToFollow;
	public void UpdateMethod() {
		
//		What LED will burn
		directionIHaveToFollow = 3;
		
//		difference between old and new position after update
		LatDifference = LatA - LatC;
		LongDifference = LongA - LongC;
		
//		Difference between destination and current position after update
		Longdistance = LongB - LongA;
		Latdistance = LatB - LatA;
		
//		You move North East pointing
		if (LongDifference > 0 && LatDifference > 0){
			if (Longdistance < 0 && Latdistance > 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance == 0 && Latdistance > 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance > 0 && Latdistance > 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance > 0 && Latdistance == 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance > 0 && Latdistance < 0){
				directionIHaveToFollow = 5;
			}
			System.out.println(directionIHaveToFollow);
		}
		
//		You move North pointing
		if (LongDifference == 0 && LatDifference > 0){
			if (Longdistance < 0 && Latdistance == 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance < 0 && Latdistance > 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance == 0 && Latdistance > 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance > 0 && Latdistance > 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance > 0 && Latdistance == 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move North West pointing
		if (LongDifference < 0 && LatDifference > 0){
			if (Longdistance < 0 && Latdistance < 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance < 0 && Latdistance == 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance < 0 && Latdistance > 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance == 0 && Latdistance > 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance > 0 && Latdistance > 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move West pointing
		if (LongDifference < 0 && LatDifference == 0){
			if (Longdistance == 0 && Latdistance < 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance < 0 && Latdistance < 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance < 0 && Latdistance == 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance < 0 && Latdistance > 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance == 0 && Latdistance > 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move South West pointing
		
		if (LongDifference < 0 && LatDifference < 0){
			if (Longdistance > 0 && Latdistance < 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance == 0 && Latdistance < 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance < 0 && Latdistance < 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance < 0 && Latdistance == 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance < 0 && Latdistance > 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move South pointing
			
		if (LongDifference == 0 && LatDifference < 0){
			if (Longdistance > 0 && Latdistance == 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance > 0 && Latdistance < 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance == 0 && Latdistance < 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance < 0 && Latdistance < 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance < 0 && Latdistance == 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move South East pointing
		
		if (LongDifference > 0 && LatDifference < 0){
			if (Longdistance > 0 && Latdistance > 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance > 0 && Latdistance == 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance > 0 && Latdistance < 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance == 0 && Latdistance < 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance < 0 && Latdistance < 0){
				directionIHaveToFollow = 5;
			}
		}
		
//		You move East Pointing
		if (LongDifference > 0 && LatDifference == 0){
			if (Longdistance == 0 && Latdistance > 0){
				directionIHaveToFollow = 1;
			}
			if (Longdistance > 0 && Latdistance > 0){
				directionIHaveToFollow = 2;
			}			
			if (Longdistance > 0 && Latdistance == 0){
				directionIHaveToFollow  = 3;
			}
			if (Longdistance > 0 && Latdistance < 0){
				directionIHaveToFollow = 4;
			}
			if (Longdistance == 0 && Latdistance < 0){
				directionIHaveToFollow = 5;
			}
		}
		
		
		}}
	
//distance = Math.sqrt((LatA-LatC)*(LatA-LatC) + (LongA-LongC)*(LongA-LongC)); << ignore this
		
	
	

